<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>

<?php 
	$USER = getAccountUserObject();
	if(!isset($_SESSION['escorts_apply_number'])){
		$_SESSION['escorts_apply_number'] = intval( $USER->getEscortsApplyNumber() );
	}
	
	$AGENT_DISCOUNT = $this->volume_discount_entity->getDiscountOfAgent($USER->getId(),$_SESSION['escorts_apply_number']);
	$iCount = 0;
	$totalPeriodDiscount = $totalVolumnDiscount = $totalPrice = 0; 
?>
<style>
	
</style>

<script type="text/javascript">
	
</script>

<form action="<?php echo site_url('agent/transaction_submit/submit_payment');?>" name="submit_payment" id="submit_payment" method="post" enctype="multipart/form-data" >

<div id="content-left">
<div id="personal-tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
	<div id="tabs-1" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
		<!-- content -->	
		 
			<div class="dashboard-info-wrapper">
				<div class="select-box">
						<table width="100%">
							<thead>
								<th><?php echo language_translate('services_page_table_head_servicename');?></th>
								<th><?php echo language_translate('services_page_table_head_details');?></th>
								<th><?php echo language_translate('services_page_table_head_period');?></th>
								<th style="text-align:right;"><?php echo language_translate('services_page_table_head_priceeuro');?></th>
							</thead>
							<tbody>
								<?php if(isset($_SESSION['SERVICES_INFO']['SUBS'])):?>
									<tr>
										<?php 
											$subs_array = getSubcriptionData_ioc($_SESSION['SERVICES_INFO']['SUBS']['type_id']);
											$iCount++;
											$totalPeriodDiscount += $_SESSION['SERVICES_INFO']['SUBS']['period_discount_price'];
											$totalVolumnDiscount += $_SESSION['SERVICES_INFO']['SUBS']['volumn_discount_price'];
											$totalPrice += $_SESSION['SERVICES_INFO']['SUBS']['payment_price'];
										?>
										<td><?php echo language_translate('services_page_subscription');?></td>
										<td><?php echo $subs_array[0];?></td>
										<td><?php echo $_SESSION['SERVICES_INFO']['SUBS']['period'];?></td>
										<td style="text-align:right;"><?php echo euroCurrencyFormat( number_format( $_SESSION['SERVICES_INFO']['SUBS']['payment_price'], 2 ) );?></td>
									</tr>
								<?php endif;?>
								
								<?php if(isset($_SESSION['SERVICES_INFO']['PLACE'])):?>
									<?php
										foreach($_SESSION['SERVICES_INFO']['PLACE'] as $k =>$v):
											$placeInfo = getPlaceListDataInfoById($v['type_id']);
									?>
									<?php if($placeInfo):?>
										<?php 
											$iCount++;
											$totalPeriodDiscount += $v['period_discount_price'];
											$totalVolumnDiscount += $v['volumn_discount_price'];
											$totalPrice += $v['payment_price'];
										?>
										<tr>
											<td><?php echo language_translate('services_page_where_do_you_work');?></td>
											<td>
												<?php echo $placeInfo['country'];?>
												<?php if($placeInfo['state']):?>
													/
													<?php echo $placeInfo['state'];?>
												<?php endif;?>
												<?php if($placeInfo['province']):?>
													/
													<?php echo $placeInfo['province'];?>
												<?php endif;?>
												<?php if($placeInfo['city']):?>
													/
													<?php echo $placeInfo['city'];?>
												<?php endif;?>
											</td>
											<td>
												<?php echo $v['period'];?>
											</td>
											<td style="text-align:right;"><?php echo euroCurrencyFormat( number_format( $v['payment_price'], 2 ) );?></td>
										</tr>
									<?php endif;?>
									<?php endforeach; ?>
								<?php endif;?> 
								
								<?php if(isset($_SESSION['SERVICES_INFO']['PACK'])):?>
									<?php foreach($_SESSION['SERVICES_INFO']['PACK'] as $k => $v):?>
											<?php 
												$pack_array = getPackListData_ioc($v['type_id']);
												$iCount++;
												$totalPeriodDiscount += $v['period_discount_price'];
												$totalVolumnDiscount += $v['volumn_discount_price'];
												$totalPrice += $v['payment_price'];
											?>
											<tr>
												<td><?php echo language_translate('services_page_add_a_pack');?></td>
												<td>
													<?php echo $pack_array[0];?>
												</td>
												<td>
													<?php echo $v['period'];?>
												</td>
												<td style="text-align:right;"><?php echo euroCurrencyFormat( number_format( $v['payment_price'], 2 ) );?></td>
											</tr>
									<?php endforeach; ?>
								<?php endif;?> 
								
								<?php if(isset($_SESSION['SERVICES_INFO']['PRI'])):?>
									<?php foreach($_SESSION['SERVICES_INFO']['PRI'] as $k=>$v):?>
										<?php 
											$pri_array = getPriorityData_ioc($v['type_id']);
											$iCount++;
											$totalPeriodDiscount += $v['period_discount_price'];
											$totalVolumnDiscount += $v['volumn_discount_price'];
											$totalPrice += $v['payment_price'];
										?>
										<tr>
											<td><?php echo language_translate('services_page_priority');?></td>
											<td>
												<?php echo $pri_array[0];?>
											</td>
											<td>
												<?php echo $v['period'];?>
											</td>
											<td style="text-align:right;"><?php echo euroCurrencyFormat( number_format( $v['payment_price'], 2 ) );?></td>
										</tr>
									<?php endforeach; ?>
								<?php endif;?> 
							
								<tr>
									<td colspan=3></td>
									<td style="text-align:right;"><?php echo euroCurrencyFormat( number_format($totalPrice, 2) );?></td>
								</tr>
							</tbody>
						</table>
				 </div>
				<div class="clear"></div>
			</div>
		
			<?php if($iCount):?>
				
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('services_page_your_discount_info');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<span id="promotion-info">
								<?php echo $_SESSION['SERVICES_INFO']['VOLUMN_DISCOUNT_AMOUNT'];?>
								<?php 
									if($_SESSION['SERVICES_INFO']['VOLUMN_DISCOUNT_UNIT'] == 'PERCENT'){
										echo '%';
									}else{
										echo '&euro;';
									}
								?>
							 </span>
						</div>
						<div class="clear"></div>
					</div>
					<div class="clear"></div>
				</div>
				
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('contract_volumn_discount');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<?php echo euroCurrencyFormat( number_format($totalVolumnDiscount,2) );?> &euro;
						</div>
						<div class="clear"></div>
					</div>
					<div class="clear"></div>
				</div>
				
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('services_page_total_period_discount');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<?php echo euroCurrencyFormat( number_format($totalPeriodDiscount,2) );?> &euro;
						</div>
						<div class="clear"></div>
					</div>
					<div class="clear"></div>
				</div>
				
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('services_page_escorts_apply_number');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box" id="apply_number">
							<?php echo ($_SESSION['SERVICES_INFO']['NUMBER_ESCORTS']);?>
						</div>
						<div class="clear"></div>
					</div>
					<div class="clear"></div>
				</div>
			
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('services_page_net_amount');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box" id="current_price">
							<?php echo euroCurrencyFormat( format($_SESSION['SERVICES_INFO']['NET_AMOUNT']) );?> &euro;
						</div>
						<div class="clear"></div>
					</div>
					<div class="clear"></div>
				</div>
				
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('contract_start_date');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<?php echo sysDateFormat($_SESSION['SERVICES_INFO']['STARTDATE'],DATE_FORMAT);?>
						</div>
						<div class="clear"></div>
					</div>
					<div class="clear"></div>
				</div>
					
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('contract_to_date');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<?php echo sysDateFormat($_SESSION['SERVICES_INFO']['ENDDATE'],DATE_FORMAT);?>
						</div>
						<div class="clear"></div>
					</div>
					<div class="clear"></div>
				</div>
					
				
				
				<div class="dashboard-info-wrapper">
					<?php 
						$records = $this->escort_news_entity->getNewsByCategoryName('Payment Info');
					?>
					<?php foreach($records as $item):?>		
						<div class="news-content">
							<?php echo $item->news;?>
						</div>
					<?php endforeach;?>
				</div>
			<!-- 	
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-right">
						<input type="submit" class="save-button" value="<?php //echo language_translate('services_page_pay');?>" /> 
						<?php //echo loader_image("id='loader_image' class='hidden'");?>
					</div>
					<div class="clear"></div>
				</div>
			 -->		 
			<?php endif;?>
			
			<div class="dashboard-info-wrapper">
				<div id="update-message"><?php echo language_translate('update_successfully_message');?></div>
				<div class="clear"></div>
			</div>
	 
		<!-- end content -->
	</div>
</div>
</div>

</form>

<?php $this->load->view('agent/right_nav'); ?>



<script type="text/javascript">
	$(document).ready(function() { 
	});	

	$(document).ready(function() {
		var options = { 
			beforeSubmit:  validateB4Submit,  
			success:       processAfterResponding   
		};	
		$('#submit_payment').ajaxForm(options); 
	});	

	function validateB4Submit(formData, jqForm, options){
		$('#loader_image').show();
		return true;
	}

	function processAfterResponding(responseText, statusText, xhr, $form) {
		$('#loader_image').hide();	
		if(responseText == 'ok'){
			updatedShow();
		}else{
			debug(responseText);
		}
	}
	
</script>